// CountView.cpp : implementation file
//

#include "stdafx.h"

#include "financedef.h"
#include "CDataFile.h"

#include "Finance.h"

#include "FinanceDoc.h"
#include "FinanceView.h"

#include "PageDateRange.h"
#include "PageLoginInfo.h"
#include "PageBakRestore.h"
#include "DlgCountDetail.h"
#include "DlgSearch.h"

#include "CountView.h"
#include "SearchView.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


extern CFinanceApp theApp;       

// Definement
// only for m_chart( IDC_CST_CHART )
// Count Type  : m_iCountType
/*************
Expense = 0, // default
Income,	// 1
Bank,	// 2
Invest	// 3
*************/

// Chart style : m_iChartStyle
/*************
Pie = 0, // default
Bar	// 1
*************/

// m_LstCount column order
// m_ordercolumn
/****************
	No,			// 0 , no use now
	Purpose,	// 1 
	SUM(Amount) // 2 , default
	COUNT(*)	// 3
****************/

/////////////////////////////////////////////////////////////////////////////
// CCountView

IMPLEMENT_DYNCREATE(CCountView, CFormView)

CCountView::CCountView()
	: CFormView(CCountView::IDD)
{
	//{{AFX_DATA_INIT(CCountView)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT

	m_ordercolumn = 2;		// default 
	m_disporder	  = desc;	// default
	m_iCountType = 0;	// default is expense
	m_iChartStyle = 0;
	m_chDateRange[0] = 0;
}

CCountView::~CCountView()
{
}

void CCountView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CCountView)
	DDX_Control(pDX, IDC_LST_COUNT, m_LstCount);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CCountView, CFormView)
	//{{AFX_MSG_MAP(CCountView)
	ON_NOTIFY(NSCS_SELECTEDITEM, IDC_CST_CHART, OnPurposeChartSelectedItem)
	ON_NOTIFY(NSCS_SELECTEDITEM, IDC_CST_FLOW, OnFlowChartSelectedItem)
	ON_COMMAND(ID_SETUP, OnSetup)
	ON_BN_CLICKED(IDC_RDO_PIE, OnRdoPie)
	ON_BN_CLICKED(IDC_RDO_BAR, OnRdoBar)
	ON_NOTIFY(LVN_COLUMNCLICK, IDC_LST_COUNT, OnColumnclickLstCount)
	ON_BN_CLICKED(IDC_RDO_ABSVAL, OnRdoAbsval)
	ON_BN_CLICKED(IDC_RDO_PERCENT, OnRdoPercent)
	ON_NOTIFY(NM_DBLCLK, IDC_LST_COUNT, OnDblclkLstCount)
	ON_COMMAND(ID_SEARCH, OnSearch)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCountView diagnostics

#ifdef _DEBUG
void CCountView::AssertValid() const
{
	CFormView::AssertValid();
}

void CCountView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CCountView message handlers

// 
// 
//--------------------------------------------------------------
void CCountView::OnInitialUpdate() 
{
	CButton		*pItemRadio;
	INT			iIDChartStyle[] = { IDC_RDO_PIE, IDC_RDO_BAR };
	

	CFormView::OnInitialUpdate();

//	CSize sizePage = GetTotalSize();
//	SetScrollSizes(MM_TEXT,sizePage);

	// <> Init inner controls
	// this code only works for a report-mode list view
	ASSERT( m_LstCount.GetStyle() & LVS_REPORT );
	
	// Gain a reference to the list control itself
	CHeaderCtrl*	pHeadCtrl = m_LstCount.GetHeaderCtrl();
	
	ASSERT( pHeadCtrl );
	VERIFY( m_FlatHeader.SubclassWindow( pHeadCtrl->GetSafeHwnd() ) );

	// <> Init list ctrl
	m_LstCount.SetExtendedStyle(LVS_EX_GRIDLINES|LVS_EX_HEADERDRAGDROP|LVS_EX_FULLROWSELECT);
	m_LstCount.SetBkColor(RGB(252,250,244)); //(RGB(244,242,220)),RGB(247,247,255)
	//InnerLst.SetTextColor(RGB(0,0,255));
	m_LstCount.SetTextBkColor(RGB(252,250,244));
	
	// <> init listview data
	m_LstCount.InsertColumn( 0,	"No.",		LVCFMT_LEFT, 22 );
	m_LstCount.InsertColumn( 1,	"Purpose",	LVCFMT_LEFT, 106 );
	m_LstCount.InsertColumn( 2,	"Amount",	LVCFMT_LEFT, 75 );
	m_LstCount.InsertColumn( 3,	"Count",	LVCFMT_LEFT, 43 );
	
	// <> _CommandPtr init
	m_pCommand.CreateInstance(__uuidof(Command));
	m_pCommand->ActiveConnection = theApp.m_pConnection.GetInterfacePtr();
	
	// Subclassing
	m_chart.SubclassDlgItem( IDC_CST_CHART, this );
	m_chart.PrepareColors(CNSChartCtrl::SimpleColors);
	m_chart.EnableBarGridLines( TRUE );
	m_chart.SetPieceValueFormat( NSCVAL_ABSVAL );
	
	m_chartOwner.SubclassDlgItem( IDC_CST_OWNER, this );
	m_chartOwner.PrepareColors(CNSChartCtrl::SimpleColors);
	m_chartOwner.SetChartStyle( NSCS_PIE );
	
	m_chartFlow.SubclassDlgItem( IDC_CST_FLOW, this );
	m_chartFlow.PrepareColors(CNSChartCtrl::SimpleColors);
	m_chartFlow.SetChartStyle( NSCS_BAR );
	m_chartFlow.SetPieceValueFormat( NSCVAL_ABSVAL );
	m_chartFlow.EnableBarGridLines( TRUE );	// for debug
	
	// <> Chart style	
	pItemRadio = (CButton*)GetDlgItem( iIDChartStyle[m_iChartStyle] );
	if( pItemRadio ) 
		pItemRadio->SetCheck( 1 );

	// <> m_chart( IDC_CST_CHART ) Bar format
	pItemRadio = (CButton*)GetDlgItem( IDC_RDO_ABSVAL );
	if( pItemRadio ) 
		pItemRadio->SetCheck( 1 );
	pItemRadio->EnableWindow( FALSE );
	pItemRadio = (CButton*)GetDlgItem( IDC_RDO_PERCENT );
	pItemRadio->EnableWindow( FALSE );
	
	// <> read ini file
	GetDateRange();

	// <> count total by FlowClass
	CountByFlow();

	// Count percent of owner
	CountByOwner();

	// Count detail of purpose by FlowClass
	CountByPurpose();
}

// 
// 
//--------------------------------------------------------------
void CCountView::CountByFlow()
{
	_RecordsetPtr	pRecSet;
	_variant_t		var;
	INT				iItem;
	CHAR			chSQL[512] = { 0 };
	DOUBLE			dbSum = 0;
	CHAR			chFlowName[50] = { 0 };
	
	
	// <> Compose SQL 
	sprintf( chSQL, "SELECT FlowClass,SUM(Amount) FROM Account WHERE " );
	strcat( chSQL, m_chDateRange );
	strcat( chSQL, " GROUP BY FlowClass" );

	// <> reset
	m_chartFlow.Empty();
	
	try
	{
		m_pCommand->CommandText = chSQL;
		pRecSet = m_pCommand->Execute( NULL, NULL, adCmdText );
		
		iItem = 0;
		while(!pRecSet->adoEOF)
		{
			var = pRecSet->GetCollect( (_variant_t)(long)0 );
			if(var.vt != VT_NULL)
				strcpy( chFlowName, (LPCSTR)_bstr_t(var) );
			else
				strcpy( chFlowName, "" );
			
			var = pRecSet->GetCollect( (_variant_t)(long)1 );
			switch( var.vt ) 
			{
			case VT_I4:	// long
				dbSum = var.lVal;
				break ;
				
			case VT_R4: // float
				dbSum = var.fltVal;
				break ;
				
			case VT_R8: // double
				dbSum = var.dblVal;
				break ;
				
			default :
				dbSum = 0;
				break ;
			}
			
			// into flow chart
			m_chartFlow.AddValue( dbSum, chFlowName );
			
			pRecSet->MoveNext();
			iItem++;
		}
		
		pRecSet->Close();
	}
	catch(_com_error *e)
	{
		AfxMessageBox(e->ErrorMessage());
	}

}

// 
//--------------------------------------------------------------------
void CCountView::GetDateRange()
{
	CDataFile		INIDF( MONEY_CFG );
	CString			csBegDate, csEndDate;
	CTime			ctBegDate, ctEndDate;
	
	
	// <> date type, begin date and end date
	ctBegDate = INIDF.GetInt( "begindate", "Date range" );
	ctEndDate = INIDF.GetInt( "enddate", "Date range" );

	ASSERT( ctBegDate > 0 );
	ASSERT( ctEndDate > 0 );

	if( wtkGetSysLanguage() == WTK_BIG5 ) 
	{	// in Big5 system, is "2005/7/12"
		csBegDate = ctBegDate.Format( "%Y/%m/%d" );  
		csEndDate = ctEndDate.Format( "%Y/%m/%d" );
	}
	else
	{	// in GB system, is "2005-7-12"
		csBegDate = ctBegDate.Format( "%Y-%m-%d" );  
		csEndDate = ctEndDate.Format( "%Y-%m-%d" );
	}
	
	ZeroMemory( m_chDateRange, sizeof(m_chDateRange) );
	
	// Confirm date range by ini file
	sprintf( m_chDateRange, "Date >=#%s# AND Date <=#%s# ", csBegDate, csEndDate );
}

// 
// 
//--------------------------------------------------------------
void CCountView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) 
{
	if( bActivate ) 
	{
		// <> read ini file
		GetDateRange();
		
		// <> count total by FlowClass
		CountByFlow();

		// Count percent of owner
		CountByOwner();
		
		// Count detail of purpose by FlowClass
		CountByPurpose();
	}
	
	CFormView::OnActivateView(bActivate, pActivateView, pDeactiveView);
}

// 
//--------------------------------------------------------------
void CCountView::OnRdoPie() 
{
	m_iChartStyle = 0;
	m_chart.SetChartStyle( NSCS_PIE );

	CButton* pItemRadio = (CButton*)GetDlgItem( IDC_RDO_ABSVAL );
	pItemRadio->EnableWindow( FALSE );
	pItemRadio = (CButton*)GetDlgItem( IDC_RDO_PERCENT );
	pItemRadio->EnableWindow( FALSE );
}

// 
//--------------------------------------------------------------
void CCountView::OnRdoBar() 
{
	m_iChartStyle = 1;
	m_chart.SetChartStyle( NSCS_BAR );

	CButton* pItemRadio = (CButton*)GetDlgItem( IDC_RDO_ABSVAL );
	pItemRadio->EnableWindow( TRUE );
	pItemRadio = (CButton*)GetDlgItem( IDC_RDO_PERCENT );
	pItemRadio->EnableWindow( TRUE );
}

//
//------------------------------------------------------------
void CCountView::OnSetup() 
{
	CPropertySheet	propsheet( "Setup" );
	CPageDateRange	CDateRange;
	CPageLoginInfo	CLoginInfo;
	CPageBakRestore	CBakResotre;
	
	
	propsheet.AddPage( &CDateRange );
	propsheet.AddPage( &CLoginInfo );
	propsheet.AddPage( &CBakResotre );
	
	if( propsheet.DoModal() == IDOK ) 
	{
		CFinanceView	*pLstView = NULL;
		CFinanceDoc		*pDoc=(CFinanceDoc*)GetDocument();
		
		if( pDoc )
			pLstView=(CFinanceView*)pDoc->GetView(RUNTIME_CLASS(CFinanceView));
		
		if( pLstView )
			pLstView->RefreshListView();
	}
}

// 
//  For Flowclass char
//--------------------------------------------------------------
void CCountView::OnFlowChartSelectedItem(NMHDR* pNMHDR, LRESULT* pResult)
{
	CString	csTmp;
	LPNMCHARTCTRL nmchart = (LPNMCHARTCTRL)pNMHDR;
	INT	iItem = nmchart->iItem;
	
	
	// <> m_csRecinfo
	csTmp = m_chartFlow.GetItemLabel( iItem );
	if( IDS_FC_EXPESE == csTmp )
	{
		m_iCountType = 0;
	}
	else if( IDS_FC_INCOME == csTmp )
	{
		m_iCountType = 1;
	}
	else if( IDS_FC_BANK == csTmp )
	{
		m_iCountType = 2;
	}
	else if( IDS_FC_INVEST == csTmp )
	{
		m_iCountType = 3;
	}
	else
	{
		m_iCountType = 0;
	}

	// Count percent of owner
	CountByOwner();
	
	// Count detail
	CountByPurpose();
	

	*pResult = FALSE;
}

// 
// m_chart (IDC_CST_CHART)
//--------------------------------------------------------------
void CCountView::CountByPurpose()
{
	_RecordsetPtr	pRecSet;
	_variant_t		var;
	CString			csTmp;
	INT				iItem;
	CHAR			chSQL[512] = { 0 };
	DOUBLE			dbSum = 0;
	CHAR			chPurName[50] = { 0 };
	CHAR			*chFlowClass[] = {
										IDS_FC_EXPESE,
										IDS_FC_INCOME,
										IDS_FC_BANK,
										IDS_FC_INVEST	
									};
	CHAR			*chOrder[] = { "ASC", "DESC" };
	CHAR			*chColumn[] = {	
									"No ", // not use now
									"Purpose ",
									"SUM(Amount) ",
									"COUNT(*) "
								};
	
	
	// <> Compose SQL 
	sprintf( chSQL, "SELECT Purpose,SUM(Amount),COUNT(*) FROM Account WHERE FlowClass='%s' AND ", chFlowClass[m_iCountType] );
	strcat( chSQL, m_chDateRange );
	strcat( chSQL, " GROUP BY Purpose ORDER BY " );
	strcat( chSQL, chColumn[ m_ordercolumn ] );
	strcat( chSQL, chOrder[ m_disporder ] );
	
	// <> reset
	m_chart.Empty();
	m_LstCount.DeleteAllItems();

	csTmp = chFlowClass[m_iCountType];
	csTmp += " info";
	m_chart.SetTitle( csTmp );
	
	try
	{
		m_pCommand->CommandText = chSQL;
		pRecSet = m_pCommand->Execute( NULL, NULL, adCmdText );
		
		iItem = 0;
		while(!pRecSet->adoEOF)
		{
			var = pRecSet->GetCollect( (_variant_t)(long)0 );
			if(var.vt != VT_NULL)
				strcpy( chPurName, (LPCSTR)_bstr_t(var) );
			else
				strcpy( chPurName, "" );
			
			var = pRecSet->GetCollect( (_variant_t)(long)1 );
			switch( var.vt ) 
			{
			case VT_I4:	// long
				dbSum = var.lVal;
				break ;
				
			case VT_R4: // float
				dbSum = var.fltVal;
				break ;
				
			case VT_R8: // double
				dbSum = var.dblVal;
				break ;
				
			default :
				dbSum = 0;
				break ;
			}
			
			// into flow chart
			m_chart.AddValue( dbSum, chPurName );

			// into listview
			sprintf( chSQL, "%d", iItem + 1 );
			m_LstCount.InsertItem( iItem, chSQL, 0 );	
			
			m_LstCount.SetItemText( iItem, 1, chPurName );	
			sprintf( chPurName, "%.2f", dbSum );
			m_LstCount.SetItemText( iItem, 2, chPurName );	

			var = pRecSet->GetCollect( (_variant_t)(long)2 );
			sprintf( chPurName, "%d", var.lVal );
			m_LstCount.SetItemText( iItem, 3, chPurName );	
			

			pRecSet->MoveNext();
			iItem++;
		}
		
		pRecSet->Close();
	}
	catch(_com_error *e)
	{
		AfxMessageBox(e->ErrorMessage());
	}
	
}

// 
// listview  column :
//	no,			// 0
//	purpose,	// 1
//	amount,		// 2
//	count		// 3
//--------------------------------------------------------------
void CCountView::OnColumnclickLstCount(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
	BOOL			bSortAscending;
	
	
	if( pNMListView->iSubItem > 0 ) // skip No. column
	{
		// If clicked on already sorted column, reverse sort order
		if(pNMListView->iSubItem == m_FlatHeader.GetSortColumn(&bSortAscending))
			bSortAscending = !bSortAscending;
		else
			bSortAscending = TRUE;
		
		m_FlatHeader.SetSortColumn(pNMListView->iSubItem, bSortAscending);
		
		// Do some sort of sorting...
		m_ordercolumn = pNMListView->iSubItem;
		m_disporder = ( bSortAscending ) ? asc : desc;
		
		// <> Refresh
		CountByPurpose();
		
		// Note!! m_iLstCurSel will be -1 after ShowAccountRec(), 
		// even if m_iLstCurSel be assigned a valid value before.
	}
	
	*pResult = 0;
}

// 
//--------------------------------------------------------------
void CCountView::OnRdoAbsval() 
{
	m_chart.EnableBarGridLines( TRUE );
	m_chart.SetPieceValueFormat( NSCVAL_ABSVAL );
}

// 
//--------------------------------------------------------------
void CCountView::OnRdoPercent() 
{
	m_chart.EnableBarGridLines( FALSE );
	m_chart.SetPieceValueFormat( NSCVAL_PERCENT );
}


#define		CCV_LINESTEP	20
#define		CCV_PAGESTEP	140
// 
//--------------------------------------------------------------
BOOL CCountView::PreTranslateMessage(MSG* pMsg) 
{
	CPoint		pt;
	BOOL		bAsKey = FALSE;
	CButton		*pItemRadio;
	INT			iIDChartStyle[] = { IDC_RDO_PIE, IDC_RDO_BAR };
	
	switch( pMsg->wParam ) 
	{
	case VK_PRIOR:
		bAsKey = TRUE;
		pt = GetScrollPosition();
		pt.y -= CCV_PAGESTEP;
		break ;

	case VK_NEXT:	
		bAsKey = TRUE;
		pt = GetScrollPosition();
		pt.y += CCV_PAGESTEP;
		break ;

	case VK_INSERT:
		pItemRadio = (CButton*)GetDlgItem( iIDChartStyle[m_iChartStyle] );
		if( pItemRadio ) 
			pItemRadio->SetCheck( 0 );
		
		OnRdoPie();
		
		pItemRadio = (CButton*)GetDlgItem( iIDChartStyle[m_iChartStyle] );
		if( pItemRadio ) 
			pItemRadio->SetCheck( 1 );
		break ;
		
	case VK_DELETE:
		pItemRadio = (CButton*)GetDlgItem( iIDChartStyle[m_iChartStyle] );
		if( pItemRadio ) 
			pItemRadio->SetCheck( 0 );

		OnRdoBar();
		
		pItemRadio = (CButton*)GetDlgItem( iIDChartStyle[m_iChartStyle] );
		if( pItemRadio ) 
			pItemRadio->SetCheck( 1 );
		break ;
		
	default :
		break ;
	}

	if( bAsKey )
	{
		// don't need check bound here.
		ScrollToPosition( pt );
	}
	
	return CFormView::PreTranslateMessage(pMsg);
}


// 
// 
//--------------------------------------------------------------
void CCountView::OnDblclkLstCount(NMHDR* pNMHDR, LRESULT* pResult) 
{
	POSITION		pos = m_LstCount.GetFirstSelectedItemPosition();
	INT				iSel = m_LstCount.GetNextSelectedItem(pos);  // Get item index
	CString			csTmp;
	CHAR			chTmp[100] = { 0 };

	
	if( iSel >= 0 )
	{
		CDlgCountDetail		dlg;
		
		// <> Pass param into dlg
		dlg.SetCOMPtr( m_pCommand );
		dlg.SetSQLdaterange( m_chDateRange );

		CSearchView		*pView = NULL;
		CFinanceDoc		*pDoc=(CFinanceDoc*)GetDocument();
		
		if( pDoc )
			pView=(CSearchView*)pDoc->GetView(RUNTIME_CLASS(CSearchView));

		if( pView )
			dlg.SetViewPtr( pView );
		
		csTmp = m_LstCount.GetItemText( iSel, 1 );
		strcpy( chTmp, csTmp );
		dlg.SetPurposeName( chTmp );
		
		if( dlg.DoModal() == IDOK )	
		{
			;
		}
	}
	
	*pResult = 0;
}


// 
//--------------------------------------------------------------
void CCountView::OnSearch() 
{
	CDlgSearch		dlg;
	
	
	if( dlg.DoModal() == IDOK ) 
	{
		CSearchView		*pView = NULL;
		CFinanceDoc		*pDoc=(CFinanceDoc*)GetDocument();
		
		if( pDoc )
			pView=(CSearchView*)pDoc->GetView(RUNTIME_CLASS(CSearchView));
		
		if( pView )
			pView->RefreshSearchView();
	}
}

// 
//  For Purpose chart
//--------------------------------------------------------------
void CCountView::OnPurposeChartSelectedItem(NMHDR* pNMHDR, LRESULT* pResult)
{
	LPNMCHARTCTRL nmchart = (LPNMCHARTCTRL)pNMHDR;
	INT	iItem = nmchart->iItem;
	
	if( iItem >= 0 ) 
		m_LstCount.SetItemState( iItem, LVIS_FOCUSED|LVIS_SELECTED, LVIS_FOCUSED|LVIS_SELECTED );
	
	*pResult = FALSE;
}

// 
//--------------------------------------------------------------
void CCountView::CountByOwner()
{
	_RecordsetPtr	pRecSet;
	_variant_t		var;
	INT				iItem;
	CHAR			chSQL[512] = { 0 };
	DOUBLE			dbSum = 0;
	CHAR			chFlowName[50] = { 0 };
	CHAR			*chFlowClass[] = {
										IDS_FC_EXPESE,
										IDS_FC_INCOME,
										IDS_FC_BANK,
										IDS_FC_INVEST	
									};
	
	
	// <> Compose SQL 
	sprintf( chSQL, "SELECT Owner,SUM(Amount) FROM Account WHERE FlowClass='%s' AND ", chFlowClass[m_iCountType] );
	strcat( chSQL, m_chDateRange );
	strcat( chSQL, " GROUP BY Owner" );
	
	// <> reset
	m_chartOwner.Empty();
	
	try
	{
		m_pCommand->CommandText = chSQL;
		pRecSet = m_pCommand->Execute( NULL, NULL, adCmdText );
		
		iItem = 0;
		while(!pRecSet->adoEOF)
		{
			var = pRecSet->GetCollect( (_variant_t)(long)0 );
			if(var.vt != VT_NULL)
				strcpy( chFlowName, (LPCSTR)_bstr_t(var) );
			else
				strcpy( chFlowName, "" );
			
			var = pRecSet->GetCollect( (_variant_t)(long)1 );
			switch( var.vt ) 
			{
			case VT_I4:	// long
				dbSum = var.lVal;
				break ;
				
			case VT_R4: // float
				dbSum = var.fltVal;
				break ;
				
			case VT_R8: // double
				dbSum = var.dblVal;
				break ;
				
			default :
				dbSum = 0;
				break ;
			}
			
			// into flow chart
			m_chartOwner.AddValue( dbSum, chFlowName );
			
			pRecSet->MoveNext();
			iItem++;
		}
		
		pRecSet->Close();
	}
	catch(_com_error *e)
	{
		AfxMessageBox(e->ErrorMessage());
	}
}

// 
// For Other View invoke
//--------------------------------------------------------------
void CCountView::RefreshCountView()
{
	// <> count total by FlowClass
	CountByFlow();
	
	// Count percent of owner
	CountByOwner();
	
	// Count detail of purpose by FlowClass
	CountByPurpose();
}

// 
// cx : Specifies the new width of the client area.
// cy : Specifies the new height of the client area.
//-----------------------------------------------------------------------
//DEL void CCountView::OnSize(UINT nType, int cx, int cy) 
//DEL {
//DEL 	RECT		rc;
//DEL 	CHAR		chTmp[100] = {0};
//DEL 
//DEL 	
//DEL 	CFormView::OnSize(nType, cx, cy);
//DEL 
//DEL 	
//DEL 	sprintf( chTmp, "cx = %d, cy = %d\n", cx, cy );
//DEL 	OutputDebugString( chTmp );
//DEL 
//DEL 	INT	iScreenW = GetSystemMetrics( SM_CXSCREEN );
//DEL 	INT	iScreenH = GetSystemMetrics( SM_CYSCREEN );
//DEL 	if( iScreenW >= 1024 ) 
//DEL 	{
//DEL 		// <> 
//DEL 		if( m_chart ) 
//DEL 		{
//DEL 			// receive the screen coordinates of the upper-left and lower-right corners
//DEL 			m_chart.GetWindowRect( &rc );
//DEL 			
//DEL 			m_chart.GetParent()->ScreenToClient( &rc );
//DEL 
//DEL 			rc.right  = cx - 150;
//DEL 			rc.bottom = cy - 5;
//DEL 			m_chart.MoveWindow( &rc, TRUE );
//DEL 		}
//DEL 	}
//DEL 	
//DEL }
